package com.eeb.dropwizardmongo.example.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotBlank;
import org.mongojack.MongoCollection;
import org.mongojack.ObjectId;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@MongoCollection(name = "assignments")
public class Assignment {

    @JsonProperty("_id")
    private String _id;

    @NotBlank
    @JsonProperty("name")
    private String name;

    @NotBlank
    @JsonProperty("description")
    private String description;

    @JsonProperty("track")
    private String track;

    @JsonProperty("badges")
    private List<String> badges;
    
    @JsonProperty("reviewers")
    private List<String> reviewers;

    @JsonProperty("submissionPoints")
    private int submissionPoints;

    @JsonProperty("reviewPoints")
    private int reviewPoints;

    @JsonProperty("status")
    private String status;

    public Assignment() {
    }

    public Assignment(@ObjectId String _id, String name, String description, String track, List<String> badges, int submissionPoints, int reviewPoints) {
        this._id = _id;
        this.name = name;
        this.description = description;
        this.track = track;
        this.badges = badges;
        this.submissionPoints = submissionPoints;
        this.reviewPoints = reviewPoints;
    }

    @ObjectId
    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTrack() {
        return track;
    }

    public void setTrack(String track) {
        this.track = track;
    }

    public List<String> getBadges() {
        return badges;
    }

    public void setBadges(List<String> badges) {
        this.badges = badges;
    }

    public void addBadge(String user) {
        if (!badges.contains(user)) badges.add(user);
    }

    public boolean removeBadge(String user) {
        return badges.remove(user);
    }

    public boolean hasBadge(String user) {
        return badges.contains(user);
    }

    public List<String> getReviewers() {
        return reviewers;
    }

    public void setReviewers(List<String> reviewers) {
        this.reviewers = reviewers;
    }

    public void addReviewer(String user) {
        if (!reviewers.contains(user)) reviewers.add(user);
    }

    public boolean removeReviewer(String user) {
        return reviewers.remove(user);
    }

    public boolean hasReviewer(String user) {
        return reviewers.contains(user);
    }

    public int getSubmissionPoints() {
        return submissionPoints;
    }

    public void setSubmissionPoints(int submissionPoints) {
        this.submissionPoints = submissionPoints;
    }

    public int getReviewPoints() {
        return reviewPoints;
    }

    public void setReviewPoints(int reviewPoints) {
        this.reviewPoints = reviewPoints;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

}